package ru.paswd.marketprice.storage.receipt.app.utils;

import lombok.experimental.UtilityClass;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@UtilityClass
public class StringUtils {

    public Map<String, String> deserializeHttpQueryMap(String params) {
        Map<String, String> map = new HashMap<>();

        String[] rows = params.split("&");
        Arrays.stream(rows).forEach( r -> {
            String[] paramItem = r.split("=");
            if (paramItem.length >= 2) {
                map.put(paramItem[0], paramItem[1]);
            }
        });

        return map;
    }
}
